package cn.itlaobing.service;

import cn.itlaobing.dao.OrderDetailsDao;
import cn.itlaobing.exception.MyException;
import cn.itlaobing.model.AreasModel;
import cn.itlaobing.model.GoodDetailModel;
import cn.itlaobing.model.GoodsDetailModel;
import cn.itlaobing.model.OffLineShopsModel;

import java.sql.SQLException;
import java.util.*;

/**
 * Created by Administrator on 2017-11-14.
 */
public class OrderDetailsService {
    private OrderDetailsDao orderDetailsDao=new OrderDetailsDao();
    //界面的全部信息，打包传输到界面展开
    public Map<String,List> getIndex() throws MyException{
        Map<String ,List> map =new HashMap<>();
        try {
            List<GoodDetailModel> listDetails=orderDetailsDao.goodDetails();
            List<GoodDetailModel> listFirstSale=orderDetailsDao.firstSale();
            List<String> listImg=orderDetailsDao.focussImg();
            map.put("goodDetails",listDetails);
            map.put("firstSale",listFirstSale);
            map.put("focussImg",listImg);
            return map;
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }
    //根据id查询该id的全部图片
    public List<String> detailImg(Integer id) throws MyException {
        try {
            return orderDetailsDao.detailImg(id);
        } catch (SQLException e) {
            e.printStackTrace();
            throw new MyException(e.getMessage());
        }
    }
    //根据id得到当前商品的详细信息
    public GoodsDetailModel queryDetailByid(Integer id) throws MyException {
        try {
            return orderDetailsDao.queryDetailByid(id);
        } catch (SQLException e) {
            e.printStackTrace();
            throw new MyException(e.getMessage());
        }
    }
    //查询全部的街道信息
    public List<AreasModel> queryAll() throws MyException {
        try {
            return orderDetailsDao.queryAll();
        } catch (SQLException e) {
            e.printStackTrace();
            throw new MyException(e.getMessage());
        }
    }
    //查询全部的线上商店信息
    public List<OffLineShopsModel> queryByid(Integer id) throws MyException {
        try {
            return orderDetailsDao.queryByid(id);
        } catch (SQLException e) {
            e.printStackTrace();
            throw new MyException(e.getMessage());
        }
    }
}


